package com.itheima.array;

/**
 * @Author 王加鑫
 * @Date 2021/4/20 16:31
 * @Version 1.0
 * 求数组的最值
 */
public class arrayTest04 {
    public static void main(String[] args) {
        int[] arr = {10,5,6,98,106,745,33,64};
        //假设arr[0]是最大值
        int max = arr[0];
        for (int i = 1; i <arr.length; i++) {
            if(max < arr[i]){
                max = arr[i];
            }
        }
        System.out.println("数组中最大的数为:"+max);

        //假设arr[0]是最小值
        int min = arr[0];
        for (int i = 0; i <arr.length ; i++) {
            if(min > arr[i]){
                min = arr[i];
            }
        }
        System.out.println("数组中最小的值是:"+min);
    }
}
